package cn.lcvc.xnc.application.web.action.backstage.waste;

import cn.lcvc.xnc.application.common.model.result.ResponseData;
import cn.lcvc.xnc.application.dao.WasteDisposalSitePatrolPictureMapper;
import cn.lcvc.xnc.application.dao.WasteDisposalSiteVirescencePictureMapper;
import cn.lcvc.xnc.application.model.WasteDisposalSitePatrol;
import cn.lcvc.xnc.application.model.WasteDisposalSitePatrolPicture;
import cn.lcvc.xnc.application.model.query.WasteDisposalMappingPictureQuery;
import cn.lcvc.xnc.application.model.query.WasteDisposalSitePatrolPictureQuery;
import cn.lcvc.xnc.application.model.query.WasteDisposalSitePatrolQuery;
import cn.lcvc.xnc.application.service.WasteDisposalSitePatrolPictureService;
import cn.lcvc.xnc.application.service.WasteDisposalSitePatrolService;
import cn.lcvc.xnc.authority.web.controller.backstage.BaseBackstageController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;


/**
 * 消纳场巡逻控制器
 *
 * @author 廖振豪
 * @date 2022/08/08
 */
@Api(tags = "后台的消纳场勘察记录管理模块")
@RestController
@RequestMapping(value = "/api/backstage/waste/wastedisposalsitepatrol")
public class WasteDisposalSitePatrolController extends BaseBackstageController<WasteDisposalSitePatrol, WasteDisposalSitePatrolQuery,Integer> {

    @Autowired
    private WasteDisposalSitePatrolService baseService;

    @Autowired
    private WasteDisposalSitePatrolPictureService wasteDisposalSitePatrolPictureService;

    @Autowired
    WasteDisposalSitePatrolPictureMapper wasteDisposalSitePatrolPictureMapper;

    @ApiOperation(value = "查询所有勘察管理记录")
    @GetMapping("/all")
    @Override
    protected ResponseData query(WasteDisposalSitePatrolQuery query) {
        return super.query(query);
    }

    @ApiOperation(value = "分页查询勘察管理列表")
    @Override
    public ResponseData query(Integer page, Integer pageSize, WasteDisposalSitePatrolQuery query){
        return super.query(page,pageSize,query);
    }

    @ApiOperation(value = "读取勘察管理信息")
    @Override
    protected ResponseData get(@PathVariable("id") Integer id) {
        return super.get(id);
    }

    @ApiOperation(value = "批量删除指定的多个勘察管理信息")
    @Override
    protected ResponseData deletes(@NotEmpty(message = "操作失败：请选择要移除的记录") Integer[] ids) {
        return super.deletes(ids);
    }


    @ApiOperation(value = "添加勘察管理记录")
    @Override
    protected ResponseData add(@Valid @RequestBody WasteDisposalSitePatrol wasteDisposalSitePatrol) {
        return super.add(wasteDisposalSitePatrol);
    }

    @ApiOperation(value = "编辑勘察管理")
    @Override
    protected ResponseData edit(@Valid @RequestBody WasteDisposalSitePatrol wasteDisposalSitePatrol) {
        return super.edit(wasteDisposalSitePatrol);
    }

//    --------------------------------拓展--------------------------------------

    @ApiOperation("勘察记录图片")
    @PostMapping("/{id}/uploadimg")
    public ResponseData uploadImage(@PathVariable @NotNull(message = "请传入勘察记录id") Integer id, @NotNull(message = "请选择上传文件") MultipartFile[] file, String remark) {
        baseService.uploadHeadImgFile(id, file, remark);
        return ResponseData.success(null);
    }

    @ApiOperation("勘察记录图片url")
    @PostMapping("/uploadimgurl")
    public ResponseData uploadImageurl(Integer id) {
        return ResponseData.success(wasteDisposalSitePatrolPictureMapper.findAll(id));
    }

    @ApiOperation("勘察记录图片url")
    @PostMapping("/uploadimgurlall")
    public ResponseData uploadImageurlall() {
        return ResponseData.success(wasteDisposalSitePatrolPictureService.findAll(null));
    }
}
